Skip to content

Unit test#1741

Merged
mappjzc merged 5 commits into
mainfrom
unit-test
Apr 26, 2022
Merged

Unit test#1741
mappjzc merged 5 commits into
mainfrom
unit-test

Conversation

@mappjzc
Copy link
Copy Markdown
Contributor

@mappjzc mappjzc commented Apr 25, 2022

Summary

Unit test for api_async_client

Key Points

  • This is a breaking change
  • New or existing documentation is updated

Description

fix some bugs and add unit test for api_async_client

Does this close any open issues?

close https://github.com/merico-dev/lake/issues/1665
close https://github.com/merico-dev/lake/issues/1737
close https://github.com/merico-dev/lake/issues/1738
close https://github.com/merico-dev/lake/issues/1739
close https://github.com/merico-dev/lake/issues/1753

Current Behavior

Describe the current behaviour of this issue, if relevant.

New Behavior

Describe the new behaviour updated in this issue, if relevant.

Screenshots

Include any relevant screenshots here.

Other Information

Any other information that is important to this PR.

mappjzc added 3 commits April 25, 2022 09:56
Add SetMaxRetry and GetMaxRetry to ApiAsyncClient for change maxRetry after created.

Nddtfjiang <zhicheng.jiang@merico.dev>
fix an error lost in DoAsync of ApiAsyncClient, after ReadAll.

Nddtfjiang <zhicheng.jiang@merico.dev>
Check if the log is nil befor log print In Log of DefaultLogger.

Nddtfjiang <zhicheng.jiang@merico.dev>
@mappjzc mappjzc force-pushed the unit-test branch 9 times, most recently from f73af83 to 56ee3ce Compare April 25, 2022 12:18
TestWaitAsync_EmptyWork
TestWaitAsync_WithWork
TestWaitAsync_MutiWork
TestDoAsync_OnceSuceess
TestDoAsync_TryAndFail
TestDoAsync_TryAndSuceess
Add gomonkey

Nddtfjiang <zhicheng.jiang@merico.dev>
Comment thread plugins/helper/api_async_client_test.go
body, err = ioutil.ReadAll(res.Body)
res.Body.Close()
res.Body = io.NopCloser(bytes.NewBuffer(body))
if err == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems res.Body will not be closed in the case of err != nil

add defer in DoAsync for close the http response.
add res.body.close() when afterReponse failed befor it return a nil res.

Nddtfjiang <zhicheng.jiang@merico.dev>
@mappjzc mappjzc merged commit b7f716b into main Apr 26, 2022
@mappjzc mappjzc deleted the unit-test branch April 26, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants